#include "Exception.h"

Exception::Exception(const std::string& d, const std::string& f, int l)
{
	type__ = "General Exception";
	description__ = d;
	file__ = f;
	line__ = l;
}

Exception::~Exception()
{
}

std::string& Exception::description()
{
	return description__;
}

std::string& Exception::file()
{
	return file__;
}

int& Exception::line()
{
	return line__;
}

const std::string& Exception::description() const
{
	return description__;
}

const std::string& Exception::file() const
{
	return file__;
}

const int& Exception::line() const
{
	return line__;
}

const std::string& Exception::type() const
{
	return type__;
}

std::ostream& operator<< (std::ostream& os, const Exception& e)
{
	os << "Exception `" << e.type() << "` catched: \"" << e.description() << "\"."; 
	if (e.file() != "")
	{
		os << " from file `" << e.file() << "`";
		if (e.line() != 0)
			os << " at line " << e.line();
	}

	return os;
}

